<template>
	<wsPage title="合伙人信息列表">
		<wsSmPanel :page="table.page" @page-change="query">
	
			<div slot="list_data">
				<ws-table :data="table.data" style="width: 100%" class="emoji-list">
					<ws-table-column align="center" prop="name" label="合伙人姓名"></ws-table-column>
					<ws-table-column align="center" label="所在国家" prop="area"></ws-table-column>
                    <ws-table-column align="center" label="详细地址" prop="location"></ws-table-column>
					<ws-table-column align="center" prop="phone" label="联系电话"></ws-table-column>
					<ws-table-column align="center" prop="email" label="邮箱" ></ws-table-column>
					<ws-table-column align="center" prop="introduce" label="自我介绍" ></ws-table-column>
					<ws-table-column align="center" prop="createDate" label="加入时间"></ws-table-column>
					
					<ws-table-column align="center" width="100" label="操作">
						<template slot-scope="scope">
							<Button @click="deleteBanner(scope.row)" type="text" size="small">删除</Button>
      					</template>
					</ws-table-column>
				</ws-table>
			</div>
		</wsSmPanel>
		
	</wsPage>
</template>

<script>
	import Util from '../../../common/util.js';
	import Common from '../../../common/common.js';
	import twemoji from 'twemoji';
	export default {
		data() {
			return {
				table: {
					data: [],
					page: {
						total: 0, //总条数
						pageNum: 1, //当前页
						pageSize: 10 //每页显示条数
					}
				}
			}
		},
		computed: {
			isEdit() {
		      return !Util.vad.isBlank(this.pre.code);
		    }
		},
		mounted() {
			this.init();
		},
		methods: {
			init() {
				this.query();
			},
			/**
			 * 表单查询
			 */
			query() {
				let pageSize = this.table.page.pageSize;
				let pageNum = this.table.page.pageNum;
				const _this = this;
				this.axios.get('/ws/ops/v2/app/partner/' + pageSize + '/' + pageNum).then(response => {
					var res = response.data;
					var resMeta = res.meta;
					if (0 == resMeta.code) {
						_this.buildPageData(res.data);
					} else {
						_this.$Message.warning(resMeta.message);
					}
				});
			},
			/**
			 * 构建表格数据
			 */
			buildPageData(data_) {
				
				this.table.data = data_.list;
				this.table.page.total = data_.total;
			},	
			
			//刷新重置查询
			refresh(){
				this.table.data = [];
				this.table.page.total = 0;
				this.table.page.pageNum = 1; //当前页
				this.table.page.pageSize = 10; //每页显示条数
				this.query();
			},
         
			/**
			 * 重置弹框表单
			 */
			resetModalForm() {
				this.$refs['modalForm'].resetFields();
				this.modal.form.code = '';
				this.modal.form.motherTongue = null;
				this.modal.form.english = null;
				this.modal.form.translatable = 0;
				this.modal.form.icon = '';
			},

			  // 删除banner推荐--提示框
            deleteBanner(_row){
                let _this=this;
                this.$confirm({
					title: "操作提示",
					width: 300,
					content: "你确认要删除该条记录吗?",
					onOk: function() {
						_this.delModalRow(_row);
					}
				});
            },


			/**
			 * 初始化模态框数据
			 */
			initModalData(code) {
				this.pre.code = code;
				let _this = this;
				this.axios.get('/ws/ops/v2/app/partner/10/1').then(response => {
					var res = response.data;
					var resMeta = res.meta;
					if (0 == resMeta.code) {
						_this.buildModalData(res.data);
					} else {
						_this.$Message.warning(resMeta.message);
					}
				});
			},
			/**
			 * 构建模态框的图片
			 */
			buildModalData(data) {
				this.modal.form.code = data.code;
				this.modal.form.motherTongue = data.motherTongue;
				this.modal.form.english = data.english;
				this.modal.form.translatable = data.translatable;
				this.modal.form.icon = data.icon;
				
				this.modal.show = true;
			},
			/**
			 * 删除
			 */
			delModalRow(row) {
				let phoneNumber = row.phone;
				let _this = this;
				this.axios.delete('/ws/ops/v2/app/partner/' + phoneNumber).then(response => {
					var res = response.data;
					var resMeta = res.meta;
					if (0 == resMeta.code) {
						_this.init();
					} else {
						_this.$Message.warning(resMeta.message);
					}
				});
			},
			/**
			 * 格式化
			 */
			tparse(str) {
				return twemoji.parse(str);
			}
		}
	}
</script>

<style scoped>
	.ws-form-select {
		width: 162px;
	}
	.title-row {
		padding: 10px;
	}
	.ws-icon {
		font-size: 30px;
	}
</style>
<style>
	img.emoji {
	    width: 2em !important;
	    height: 2em !important;
	}
</style>